<template>
  <div class="admin-module">
    <h3>{{ blogStore.currentBlog.title }}</h3>

    <MdPreview editorId="blog-id" v-model="blogStore.currentBlog.content"/>

    <div class="button-container">
      <el-button type="primary" @click="backClick">返回</el-button>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { onMounted } from 'vue'
import { useBlogStore } from '@/store/blog.ts'
import { MdPreview } from 'md-editor-v3'
import 'md-editor-v3/lib/style.css'
import { useRouter, useRoute } from 'vue-router'

const route = useRoute()
const router = useRouter()
const blogStore = useBlogStore()


onMounted(async () => {
  const blogId = route.params.id as number
  await blogStore.queryAdminBlogById(blogId)
  blogStore.newBlog = blogStore.currentBlog
})

const backClick = () => {
  router.push('/admin/blog/article')
}
</script>
